<template>
  <h3>Child组件</h3>
  <h3>age:{{ age }}</h3>
  <h3>length:{{ length }}</h3>
</template>
<script lang="ts">
import { computed, defineComponent, Ref, toRef } from "vue";
function useNumberLength(age: Ref) {
  return computed(() => {
    return age.value.toString().length;
  });
}
export default defineComponent({
  name: "Child",
  props: {
    age: {
      type: Number,
      default: 0,
    },
  },
  setup(props) {
    const length = useNumberLength(toRef(props, "age"));
    return { length };
  },
});
</script>